//
//  HCustomToolView.m
//  逆向工程
//
//  Created by 9188 on 2017/5/27.
//  Copyright © 2017年 朱同海. All rights reserved.
//

#import "HCustomToolView.h"


@interface HCustomToolView ()

@property (nonatomic, strong) UIButton *bombBtn;
@property (nonatomic, strong) UIButton *settingBtn;
@property (nonatomic, strong) UIButton *stopBtn;

@end

@implementation HCustomToolView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

- (void)createUI {
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.bombBtn];
    [self addSubview:self.settingBtn];
    [self addSubview:self.stopBtn];
}

- (void)btnClick:(UIButton *)button {
    if (self.BtnActionBlock) {
        self.BtnActionBlock(button.tag);
    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.bombBtn.frame = CGRectMake(5, 5, 40, self.frame.size.height - 10);
    self.stopBtn.frame = CGRectMake(65, 5, 40, self.frame.size.height - 10);
    self.settingBtn.frame = CGRectMake(125, 5, 40, self.frame.size.height - 10);

}

#pragma mark - lazy
- (UIButton *)bombBtn {
    if (!_bombBtn) {
        _bombBtn = [[UIButton alloc] init];
        _bombBtn.tag = 1214;
        [_bombBtn setTitleColor:[[UIColor greenColor] colorWithAlphaComponent:0.7] forState:UIControlStateNormal];
        [_bombBtn setTitle:@"轰炸" forState:UIControlStateNormal];
        _bombBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [_bombBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        _bombBtn.layer.borderColor = [UIColor greenColor].CGColor;
        _bombBtn.layer.borderWidth = 0.5f;
        _bombBtn.layer.cornerRadius = 10;
        _bombBtn.layer.masksToBounds = YES;
    }
    return _bombBtn;
}

- (UIButton *)settingBtn {
    if (!_settingBtn) {
        _settingBtn = [[UIButton alloc] init];
        _settingBtn.tag = 1215;
        [_settingBtn setTitleColor:[[UIColor greenColor] colorWithAlphaComponent:0.7] forState:UIControlStateNormal];
        [_settingBtn setTitle:@"设置" forState:UIControlStateNormal];
        _settingBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [_settingBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        _settingBtn.layer.borderColor = [UIColor greenColor].CGColor;
        _settingBtn.layer.borderWidth = 0.5f;
        _settingBtn.layer.cornerRadius = 10;
        _settingBtn.layer.masksToBounds = YES;
    }
    return _settingBtn;
}

- (UIButton *)stopBtn {
    if (!_stopBtn) {
        _stopBtn = [[UIButton alloc] init];
        _stopBtn.tag = 1216;
        [_stopBtn setTitleColor:[[UIColor greenColor] colorWithAlphaComponent:0.7] forState:UIControlStateNormal];
        [_stopBtn setTitle:@"停止" forState:UIControlStateNormal];
        _stopBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [_stopBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        _stopBtn.layer.borderColor = [UIColor greenColor].CGColor;
        _stopBtn.layer.borderWidth = 0.5f;
        _stopBtn.layer.cornerRadius = 10;
        _stopBtn.layer.masksToBounds = YES;
    }
    return _stopBtn;
}

@end
